const express = require( 'express' );
const bodyParser = require( 'body-parser' );
const textConfig=require('./web/text.js');
const { file } = require( './web/text.js' );
const app = express();
app.listen( 8080 );

app.use( bodyParser( { extended: false } ) );
let count = 3;
let i = 5;
app.post( '/login', ( req, res ) => { 
    console.log( req.body );
    const userMsg = req.body;
    count--;
    if ( count > 0 ) {
        i--;
        if ( i > 0 ) {
            if ( userMsg.username == file.name && userMsg.password == file.password ) {
                console.log( '登录成功' );
                res.send( '登录成功' );
                console.log( count );
            }
        } else { 
            console.log( '密码已经输错5次，明天再试' );
            res.send( '密码已经输错5次，明天再试' );
        }
    }
    else { 
        res.send( '今天登录次数超过3次' );
        console.log('今天登录次数超过3次');
        return;
    }
    
})